(function () {
  //获取元素
  let leftBtn = document.querySelector("#leftBtn");
  let rightBtn = document.querySelector("#rightBtn");
  let picList = document.querySelector("#picList");
  let cnt = 0;
  //函数节流
  let lock = true;
  //右按钮
  rightBtn.onclick = function () {
    if (!lock) return;
    lock = false;
    if (cnt == 2) {
      setTimeout(() => {
        lock = true;
      }, 50);
      return;
    }
    cnt++;
    picList.style.transform = `translateX(${-(171 + 48) * cnt}px)`;
    setTimeout(() => {
      lock = true;
    }, 50);
  };

  //左按钮
  leftBtn.onclick = function () {
    if (!lock) return;
    lock = false;
    if (cnt == 0) {
      setTimeout(() => {
        lock = true;
      }, 50);
      return;
    }
    cnt--;
    picList.style.transform = `translateX(${-(171 + 48) * cnt}px)`;
    setTimeout(() => {
      lock = true;
    }, 50);
  };
})();
